import Vue from 'vue'
import VueCookie from 'vue-cookie'
Vue.use(VueCookie)

import { CookieDomain } from '../config.js'
let cookieConfig = {}
if (CookieDomain !== '') {
  cookieConfig = { domain: CookieDomain, expires: '60s' }
}

export function saveCookie(name,value) {
  Vue.cookie.set(name, value, cookieConfig)
}

export function getCookie(name) {
  return Vue.cookie.get(name)
}

export function removeCookie(name) {
  Vue.cookie.delete(name, cookieConfig)
}

export function signOut() {
  Vue.cookie.delete('token', cookieConfig)
}

export function isLogin() {
  return !!Vue.cookie.get('token')
}